﻿using Smobiler.Core;
using Smobiler.Core.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FubiManger.UI;
namespace FubiManger.Controls
{
    ////ToolboxItem用于控制是否添加自定义控件到工具箱，true添加，false不添加
    //[System.ComponentModel.ToolboxItem(true)]
    partial class activityscontrol : Smobiler.Core.Controls.MobileUserControl
    {
        public activityscontrol() : base()
        {
            //This call is required by the SmobilerUserControl.
            InitializeComponent();
        }
        /// <summary>
        /// 商品名称
        /// </summary>
        public string goods_name { get; set; }
        /// <summary>
        /// 封面
        /// </summary>
        public string cover { get; set; }
        /// <summary>
        /// 活动价
        /// </summary>
        public string discount_price { get; set; }
        /// <summary>
        /// 市场价
        /// </summary>
        public string market_price { get; set; }
        /// <summary>
        /// 审核状态
        /// </summary>
        public string audit_status { get; set; }
        /// <summary>
        /// 活动编号
        /// </summary>
        public string activityid { get; set; }
        /// <summary>
        /// 活动开始时间
        /// </summary>
        public string start_time { get; set; }
        /// <summary>
        /// 审核失败原因
        /// </summary>
        public string reason { get; set; }
        /// <summary>
        /// 活动结束时间
        /// </summary>
        public string end_time { get; set; }
        /// <summary>
        /// 活动类型
        /// </summary>
        public string activity_type { get; set; }
        private void activityscontrol_Load(object sender, EventArgs e)
        {
            imgcover.ResourceID = @"C:\fbimage\" + cover;
            lblname.Text = goods_name;//商品名称
            lblprice.Text ="￥"+ discount_price;//活动价格
            lblmarkprice.Text = "原价:￥" + market_price;//原价
            lbltime.Text = start_time;//开始时间
            if (audit_status == "1")
                lblisstatus.Text = "审核中";
            else if (audit_status == "2")
                lblisstatus.Text = "通过";
            else if (audit_status == "3")
                lblisstatus.Text = "未通过";
            DateTime dt = Convert.ToDateTime(start_time);//开始时间
            DateTime dt1 = DateTime.Now;
            DateTime dtendt = Convert.ToDateTime(end_time);//结束时间
            if (DateTime.Compare(dt, dt1) > 0)
            {
                lblstatus.Text = "未开始";
                lblstatus.BackColor = System.Drawing.Color.FromArgb(237, 246, 255);
                lblstatus.ForeColor = System.Drawing.Color.FromArgb(76, 151, 230);
            }
            else if ( DateTime.Compare(dtendt, dt1) >= 0)
            {
                lblstatus.Text = "进行中";
                lblstatus.BackColor = System.Drawing.Color.FromArgb(255, 244, 232);
                lblstatus.ForeColor = System.Drawing.Color.FromArgb(254, 177, 101);
            }
            else if (DateTime.Compare(dtendt, dt1) < 0)
            {
                lblstatus.Text = "已结束";
                lblstatus.BackColor = System.Drawing.Color.DarkGray;
                lblstatus.ForeColor = System.Drawing.Color.DimGray;
            }

        }

        private void btnstatus_Press(object sender, EventArgs e)
        {
            ReasonForm frm = new ReasonForm();
            frm.actid = activityid;
            this.Form.Show(frm, true);
        }
        /// <summary>
        /// 查看详情
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void panel1_Press(object sender, EventArgs e)
        {
            AddactivityForm frm = new AddactivityForm();
            frm.stype = "2";//更新
            frm.actvid = activityid;//活动编号
            frm.activity_type = activity_type;//活动类型
            this.Form.Show(frm);
        }
    }
}